#include <m64p_frontend.h>
#include <stdio.h>

int main(int argc, char *argv[])
{
	long fsize = 0;
	FILE* file;
	unsigned char *buffer;

	CoreStartup();

	file = fopen("testrom.v64", "rb");
	fseek(file, 0, SEEK_END);
	fsize = ftell(file);
	fseek(file, 0, SEEK_SET);

	buffer = (unsigned char *)malloc(fsize);
	fread(buffer, 1, fsize, file);
	fclose(file);

	CoreDoCommand(M64CMD_ROM_OPEN, fsize, buffer);
	
	if (CoreDoCommand(M64CMD_EXECUTE, 0, NULL) != M64ERR_SUCCESS)
	{
		printf("Failed to execute emulator");
	}

	printf("\nPress ENTER to continue");
	getc(stdin);

	return 0;
}